<?php


/**
* CakePHP Routines Plugin
* http://cake-routines-plugin.googlecode.com
*
* @package routines
* @subpackage routines.controllers.components
* @author Ivan Chistyakov <zetruger@gmail.com>
* @version $Id: captcha.php 60 2010-06-10 18:34:56Z zetruger@gmail.com $
* @link $HeadURL: http://cake-routines-plugin.googlecode.com/svn/trunk/controllers/components/captcha.php $
* @license MIT License (http://opensource.org/licenses/mit-license.php)
*/


class CaptchaComponent extends Object {

var $components = array('Session');

function kcaptcha() {
	if (App::import('Vendor', 'Routines.KCAPTCHA', array('file' => 'kcaptcha' . DS . 'kcaptcha.php'))) {
		$kcaptcha = new KCAPTCHA();
		$this->Session->write('Captcha', $kcaptcha->getKeyString());
	} else {
		$this->cakeError('error404');
	}
}

function securimage() {
	if (App::import('Vendor', 'Routines.Securimage', array('file' => 'securimage' . DS . 'securimage.php'))) {
		$securimage = new Securimage();
		$securimage->ttf_file = APP . 'plugins' . DS . 'routines' . DS . 'vendors' . DS . 'securimage' . DS . 'elephant.ttf';
		//$securimage->gd_font_file = APP . 'plugins' . DS . 'routines' . DS . 'vendors' . DS . 'securimage' . DS . 'gdfonts' . DS . 'bubblebath.gdf';
		$this->Session->write('Captcha', $securimage->getCode());
		$securimage->show();
	} else {
		$this->cakeError('error404');
	}
}

function securimageAudio() {
	if (App::import('Vendor', 'Routines.Securimage', array('file' => 'securimage' . DS . 'securimage.php'))) {
		$securimage = new Securimage();
		$this->Session->write('Captcha', $securimage->getCode());
		$securimage->outputAudioFile();
	} else {
		$this->cakeError('error404');
	}
}

function sumcaptcha() {
	if (App::import('Vendor', 'Routines.SumCaptcha', array('file' => 'sumcaptcha' . DS . 'sumcaptcha.php'))) {
		$sumcaptcha = new SumCaptcha();
		$this->Session->write('Captcha', $sumcaptcha->getSum());
		$sumcaptcha->show();
	} else {
		$this->cakeError('error404');
	}
}

}


?>